﻿namespace RndMaterialDisposal.Extensions.Authorization
{
    /// <summary>
    /// 存储用户信息
    /// 只是测试使用,实际动态获取
    /// </summary>
    public static class UsersData
    {
        public static readonly List<User> Users = new List<User>();
        static UsersData()
        {
            // 添加一个管理员
            Users.Add(new User
            {
                Name = "admin",
                Email = "admin@qq.com",
                Role = new Role
                {
                    UserPermission = new List<string>
                    {
                        "User",
                        "User:List",
                        "User:Create",
                        "User:Delete",
                        "User:Update"
                    }
                }
            });

            // 没有删除权限
            Users.Add(new User
            {
                Name = "zhangsan",
                Email = "zhangsan@qq.com",
                Role = new Role
                {
                    UserPermission = new List<string>
                    {
                         "User",
                        "User:List",
                        "User:Create",
                        "User:Update"
                    }
                }
            });
        }
    }

    public class User
    {
        public string Name { get; set; }
        public string Email { get; set; }
        public Role Role { get; set; }
    }

    /// <summary>
    /// 这里的存储角色的策略授权，字符串数字等都行，只要能够存储表示就OK
    /// <para>在这里没有任何意义，只是标识的一种方式</param>
    /// </summary>
    public class Role
    {
        public List<string> UserPermission { get; set; }
    }
}
